<template>
<div>


  <el-form :inline="true" :model="addAdmArticlesData" class="demo-form-inline">
    <el-form-item label="用品">
      <el-input v-model="addAdmArticlesData.name" placeholder="用品"></el-input>
    </el-form-item>
    <el-form-item label="数量">
      <el-input v-model="addAdmArticlesData.number" type="number" placeholder="数量"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="addAdmArticlesBtn">申请</el-button>
    </el-form-item>
  </el-form>


</div>
</template>

<script>

// import FlowUtils from "../../../utils/FlowUtils";

export default {
  name: "AddAdmArticles",
  data(){
    return{
      addAdmArticlesData:{
        name:"",
        number:"",
        applicant:""
      }
    }
  },
  created() {
  },
  methods:{
    addAdmArticlesBtn(){

      const loading = this.$loading({
        lock: true,
        text: '正在载入...',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });


      this.addAdmArticlesData.applicant=JSON.parse(localStorage["user"])[0].id//当前登陆者id
      // FlowUtils.addFlow(this.$http,"admarticles" ,this.addAdmArticlesData)
      //     .then( //成功回调
      //         this.$emit("addOk")
      //     )
      //     .catch()
      this.$http.post("admarticles",this.addAdmArticlesData)
          .then( () => {//成功回调
            setTimeout(() => {
              loading.close();
            });
            this.$message({
              message: '添加成功!',
              type: 'success'
            });
            this.$emit("addOk")
          })
          .catch()


     //
     //  this.$http.post("admarticles" ,this.addAdmArticlesData)
     //  .then(res => {
     //    console.log(res)
     //  })

    }
  }

}
</script>

<style scoped>

</style>